home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / manual-p / linuxman.sh < prev    next >
Internet Message Format  |  1996-11-17  |  6KB

  1. From saw@hallc1.cebaf.gov Wed Oct 20 16:03:21 1993
  2. Date: Wed, 20 Oct 1993 03:32:44 GMT
  3. From: "Stephen A. Wood" <saw@hallc1.cebaf.gov>
  4. Subject: WWW Linux man reader
  5.  
  6. I hacked up a script I found that can make your linux man pages World
  7. Wide Web readable.  You just need to add some lines to your /etc/services
  8. and /etc/inetd.conf files, and put the following script in
  9. /usr/local/htfiled (or whereever inetd.conf points.)  Then from a WWW
  10. browser such as xmosaic, open the URL http://yourhostname:1235/man
  11. You do need to have networking up with at least  loopback.
  12.  
  13. This way of reading man pages puts in a link wherever a man page refers to
  14. another man page, so it is easy to jump around the man pages.  I find it
  15. more pleasant than using xman.
  16.  
  17. #!/bin/bash
  18. #bogus http server functions, directory browser, man page reader, etc.
  19. #install a service htfile in /etc/services and /etc/inetd.conf as follows:
  20. #services:htfile                1235/tcp                
  21. #inetd.conf:htfile stream tcp nowait www /usr/local/htfiled htfiled
  22. #(Make sure you have a www dummy account).  makewhatis must  have been run so
  23. # that /usr/man/whatis exists and man -k works.
  24. #
  25. # To access, use the URL http://hostname:1235/man
  26. #
  27. # This file was modified by Stephen Wood (saw@cebaf.gov) from a ksh version for
  28. # IRIX 4.0 man pages.  It's copyright status is unknown.
  29. exec 2>&1
  30.  
  31. #read get command line
  32. read get path
  33.  
  34. #get rid of return character at end of get command
  35. ###path=`echo $path|sed s///`
  36. path=`echo $path|sed s/.$//`
  37.  
  38. #parse arguments with / delimeter (this was a bad idea)
  39. dir="$path"
  40. cmd=`expr "$dir//" : '/\([^/]*\)/'`
  41. args=`expr "$dir" : '/[^/]*/\(.*\)'`
  42. dir=`expr "$dir" : '/[^/]*\(/.*\)'`
  43. arg=`expr "$dir//" : '/\([^/]*\)/'`
  44. dir=`expr "$dir" : '/[^/]*\(/.*\)'`
  45. arg2=`expr "$dir//" : '/\([^/]*\)/'`
  46.  
  47. case $cmd in
  48.  
  49. date) echo "<TITLE>Date and Time now</TITLE><H1>"`date`"</H1>Wanna see it again?  Here it is: "`date`".<P>"
  50. ;;
  51.  
  52. man) 
  53.         if [ "$arg2" = "" ]; then pre=""
  54.         else pre="../"; fi
  55.         case "$arg" in
  56.         "")
  57.         echo "<TITLE>Linux Manual Pages</TITLE><H1>Linux Manual Pages</H1>"
  58.         echo "These are links to the Linux manual pages.  You can"
  59.         echo "look for information in several ways."
  60.         echo "<p><dl>"
  61.         echo "<dt><a name=id1 href=man/index>Keyword Search</a>"
  62.         echo "<dd>where you can do a full text search for man pages"
  63.         echo "that contain the keyword you specify."
  64.         echo "<dt><a name=id2 href=man/section>By section</a>"
  65.         echo "<dd>where you can browse the names of the man pages"
  66.         echo "in a section and choose items of interest."
  67.         echo "</dl>"
  68.         exit
  69.         ;;
  70.         index*)
  71. ## I (saw) don't know what this ifs stuff does.  It seems not to work without it though.
  72.         ifs="$IFS"
  73.             IFS="?$IFS"
  74.             set $path
  75.         dir=$1
  76.         if [ "$2" = "" ]; then
  77.                 echo "<ISINDEX>"
  78.                 echo "<title>linux index</title>"
  79.                 echo "<h1>linux</h1>"
  80.         echo "Type a keyword to search for in the Linux man pages."
  81.         else
  82.                 echo "<TITLE>Find Linux Manual $2</TITLE><H1>$2 Keyword search</H1>"
  83.                 echo "<DL>"
  84. ### The big substitute a few lines below (and repeated later), attempts to get
  85. ### the first command mentioned on the line, since there may be only a man page for
  86. ### that command and not the others (since they are all covered in one man page.)
  87. ### This seems to work with the set of Linux man pages I have.
  88.                 man -k $2|sed '
  89. s/\&/\&/g
  90. s/</\</g
  91. s/>/\>/g
  92. s/^/<DT>/
  93. s/[      ]*- /<DD>- /
  94. s/()//
  95. s|<DT>([A-Za-z4][_A-Za-z0-9+]\{1,\})(.*)[ \t]*\(([1-9n][A-Za-z1-9]*)\)|<DT><A HREF=\1\/\3>\1(\3)<\/A>\2|g
  96. s/$//'
  97.                 echo "</DL>"
  98.         fi
  99.         exit
  100.             ;;
  101.         section*)
  102.         ifs="$IFS"
  103.         IFS="?$IFS"
  104.         set $path
  105.         dir=$1
  106.         if [ "$2" = "" ]; then
  107.             echo "<title>Man pages, by section, for Linux</title>"
  108.             echo "<h1>Man pages, by section, for Linux</h1>"
  109.             echo "Choose a section of the linux manual from the list below:<p>"
  110.                 echo "Section <a href=section?1>1</a> - Commands<p>"
  111.                 echo "Section <a href=section?2>2</a> - System calls<p>"
  112.                 echo "Section <a href=section?3>3</a> - Library calls<p>"
  113.                 echo "Section <a href=section?4>4</a> - Devices<p>"
  114.                 echo "Section <a href=section?5>5</a> - File formats<p>"
  115.                 echo "Section <a href=section?6>6</a> - Games<p>"
  116.                 echo "Section <a href=section?7>7</a> - Miscellaneous useful information<p>"
  117.                 echo "Section <a href=section?8>8</a> - System Administration<p>"
  118.                 echo "Section <a href=section?n>n</a> - New<p>"
  119.         else
  120.         echo "<title>Linux man pages for section $2</title><h1>Linux man pages for section $2</h1>"
  121.         echo "Select this to go back up to the section list for the Linux"
  122.         echo "man pages, or choose a man page from the list below:<p>"
  123.         cat /usr/man/whatis | grep \($2\) |sed '
  124. s/\&/\&/g
  125. s/</\</g
  126. s/>/\>/g
  127. s/^/<DT>/
  128. s/[      ]*- /<DD>- /
  129. s/()//
  130. s|<DT>([A-Za-z4][_A-Za-z0-9+]\{1,\})(.*)[ \t]*\(([1-9n][A-Za-z1-9]*)\)|<DT><A HREF=\1\/\3>\1(\3)<\/A>\2|g
  131. s/$//'
  132.                 echo "</DL>"
  133.         fi
  134.         exit
  135.         ;;
  136.         esac
  137.         echo "<TITLE>Linux Manual Page: $arg $arg2</TITLE><H1>Linux $arg.$arg2</H1>"
  138.         echo "<PRE>"
  139. ##This sed replaces <'s, >'s and &'s with the right html directive.  It also
  140. ##searches for what appear to be man page references and puts in links to those pages.
  141.         man $arg2 $arg|col -bx|sed '
  142. s/\&/\&/g
  143. s/</\</g
  144. s/>/\>/g
  145. s|([A-Za-z4][_A-Za-z0-9+]\{1,\})[ \t]*\(([1-9n][A-Za-z1-9]*)\)|<A HREF='$pre'\1\/\2>\1(\2)<\/A>|g
  146. s/$//'
  147. ;;
  148.  
  149. *) echo unrecognized command. $cmd
  150. ;;
  151.  
  152. esac
  153. exit
  154. --
  155.  
  156. ---------------------------------------------------------
  157. Stephen A. Wood                       CEBAF/SURA
  158. Internet: saw@hallc1.cebaf.gov            Mail Stop 12H
  159. Internet: saw@cebaf.gov            12000 Jefferson Avenue
  160. Bitnet:   saw@cebaf                Newport News, VA 23606
  161.  
  162. Phone: (804)249-7367        Office: CEBAF Center C121
  163. FAX:   (804)249-7363
  164.  
  165.